//
//  ClassDataVewCell.m
//  Feel_at_home
//
//  Created by dlios on 15/9/28.
//  Copyright © 2015年 Feel_at_home. All rights reserved.
//

#import "ClassDataVewCell.h"
#import "WidthAndHeight.pch"
#import <UIImageView+WebCache.h>

@implementation ClassDataVewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.picImage = [[UIImageView alloc] init];
        self.titleLabel = [[UILabel alloc] init];
        self.titleView = [[UIView alloc] init];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.picImage.backgroundColor = [UIColor cyanColor];
    self.picImage.frame = CGRectMake(5, 5, CELLWIDTH - 10, CELLHEIGH - 10);
    [self.contentView addSubview:self.picImage];
    self.picImage.layer.cornerRadius = 8.0;
    self.picImage.layer.masksToBounds = YES;
    
    self.titleView.frame = CGRectMake(0, CELLHEIGH - 55, CELLWIDTH - 10, 40);
    self.titleView.backgroundColor = [UIColor colorWithRed:250 / 255.0 green:245 / 255.0 blue:232 / 255.0 alpha:0.7];
    [self.picImage addSubview:self.titleView];
    
    self.titleLabel.frame = CGRectMake(0, 0, CELLWIDTH - 10, 40);
    self.titleLabel.textColor = [UIColor blackColor];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.titleView addSubview:self.titleLabel];
    
}

- (void)setClassM:(ClassModel *)classM
{
    [self.picImage sd_setImageWithURL:[NSURL URLWithString:classM.cover_image_url] placeholderImage:[UIImage imageNamed:@"xinqing"]];
    self.titleLabel.text = classM.title;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
